package com.bmit.ma.mapper;

import com.bmit.ma.model.Manager;
import com.bmit.ma.model.ManagerExample;
import com.bmit.ma.model.ManagerKey;

import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface ManagerMapper {
    @SelectProvider(type = ManagerSqlProvider.class, method = "countByExample")
    long countByExample(ManagerExample example);

    @DeleteProvider(type = ManagerSqlProvider.class, method = "deleteByExample")
    int deleteByExample(ManagerExample example);

    @Delete({
            "delete from manager",
            "where id = #{id,jdbcType=INTEGER}",
            "and name = #{name,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(ManagerKey key);

    @Insert({
            "insert into manager (id, name, ",
            "password)",
            "values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
            "#{password,jdbcType=VARCHAR})"
    })
    int insert(Manager record);

    @InsertProvider(type = ManagerSqlProvider.class, method = "insertSelective")
    int insertSelective(Manager record);

    @SelectProvider(type = ManagerSqlProvider.class, method = "selectByExample")
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR, id = true),
            @Result(column = "password", property = "password", jdbcType = JdbcType.VARCHAR)
    })
    List<Manager> selectByExample(ManagerExample example);

    @Select({
            "select",
            "id, name, password",
            "from manager",
            "where id = #{id,jdbcType=INTEGER}",
            "and name = #{name,jdbcType=VARCHAR}"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR, id = true),
            @Result(column = "password", property = "password", jdbcType = JdbcType.VARCHAR)
    })
    Manager selectByPrimaryKey(ManagerKey key);

    @Select({
            "select",
            "id, name, password",
            "from manager"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR, id = true),
            @Result(column = "password", property = "password", jdbcType = JdbcType.VARCHAR)
    })
    List<Manager> selectList();

    @UpdateProvider(type = ManagerSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Manager record, @Param("example") ManagerExample example);

    @UpdateProvider(type = ManagerSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") Manager record, @Param("example") ManagerExample example);

    @UpdateProvider(type = ManagerSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Manager record);

    @Update({
            "update manager",
            "set password = #{password,jdbcType=VARCHAR}",
            "where id = #{id,jdbcType=INTEGER}",
            "and name = #{name,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Manager record);
}